﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using DataAccess.SqlClient;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
  public  class sy_newsDAL
    {

        /// <summary>
        /// 首页新闻动态显示
        /// </summary>
        /// <returns></returns>
        public static dynamic NewsShow()
        {
            var q = new SqlQuery
            {
                CommandText = " select top 10 ROW_NUMBER() over(order by ntime) nid ,  * from news",
            };
            var dt = SqlDataAccess.ExecDataset(q).Tables[0];//连接数据库，获取新闻动态表
            var list = new List<dynamic>();
            foreach (var dr in dt.Select())
            {
                list.Add(

                    new
                    {
                        newsID = dr.Field<Guid>("newsID"),
                        ntime = dr.Field<DateTime>("ntime").ToString(),
                        Title = dr.Field<string>("Title"),
                        Content = dr.Field<string>("Content"),
                    }
                    );
            }
            return list;
        }
    }
}
